View Javadoc
1 //============================================================================== 2 // file : JDOTest.java 3 // project: East Networks News System 4 // 5 // last change: date: $Date: 2003/09/10 09:28:37 $ 6 // by: $Author: bitiboy $ 7 // revision: $Revision: 1.1 $ 8 //------------------------------------------------------------------------------ 9 // copyright: GNU GPL Software License (see class documentation) 10 //============================================================================== 11 package net.eastol.news.test; 12 13 import com.justhis.jdo.JDOContext; 14 15 import com.justhis.util.exception.PropertiesFileReadException; 16 17 import net.eastol.news.jdo.bean.NewsClass; 18 19 import java.io.FileNotFoundException; 20 import java.io.IOException; 21 22 import java.util.Iterator; 23 24 import javax.jdo.Extent; 25 import javax.jdo.PersistenceManager; 26 27 28 /* 29 * TODO 30 * @author <a href="http://blog.ejb.cn">acai</a> 31 * 32 * @version $Revision: 1.1 $ 33 */ 34 public class JDOTest { 35 //~ Constructors ----------------------------------------------------------- 36 37 public JDOTest() { 38 super(); 39 40 41 } 42 43 //~ Methods ---------------------------------------------------------------- 44 45 /*** 46 * TODO 47 * 48 * @throws FileNotFoundException TODO 49 * @throws IOException TODO 50 * @throws PropertiesFileReadException TODO 51 */ 52 public void writeClass() 53 throws FileNotFoundException, IOException, 54 PropertiesFileReadException { 55 NewsClass hd = new NewsClass(); 56 System.out.println("first time: " + hd); 57 58 JDOContext jctx = JDOContext.getContext(); 59 60 PersistenceManager pm = jctx.getPersistenceManager(); 61 pm.currentTransaction().begin(); 62 63 //hd.test = " This is a Testfrom JCredo!"; 64 pm.makePersistent(hd); 65 pm.currentTransaction().commit(); 66 67 String oidNum = pm.getObjectId(hd).toString(); 68 69 hd = null; 70 71 pm.currentTransaction().begin(); 72 73 Object oid = pm.newObjectIdInstance(NewsClass.class, oidNum); 74 hd = (NewsClass) pm.getObjectById(oid, false); 75 76 //hd.test = "??????????!"; 77 pm.currentTransaction().commit(); 78 79 Extent e = pm.getExtent(NewsClass.class, false); 80 81 for (Iterator i = e.iterator(); i.hasNext();) { 82 hd = (NewsClass) i.next(); 83 System.out.println(hd); 84 85 // System.out.println("===============================" + hd.test); 86 // System.out.println("===============================" + 87 // hd.getTest()); 88 } 89 90 e.closeAll(); 91 pm.close(); 92 } 93 } 94 95 96 /* 97 * $Log: JDOTest.java,v $ 98 * Revision 1.1 2003/09/10 09:28:37 bitiboy 99 * *** empty log message *** 100 * 101 * 102 */

This page was automatically generated by Maven